﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using ZOIL.Framework.Presentation;
using System.Windows;

namespace ZOIL.Library.Behaviors
{
    public class ZObjectManipulationInformation
    {
        public ZObjectManipulationInformation(ZComponent comp)
        {
            ComponentBeingManipulated = comp;
            Touches = new List<TouchDevice>();
            IDs = new List<int>();
        }

        public double Left { get; set; }
        public double Top { get; set; }
        public List<TouchDevice> Touches { get; set; }
        public List<int> IDs { get; set; }
        //This is used for performance improvements, as the Manipulation Processor sends many more deltas than for example the mouse
        public bool DeltaFired = false;

        public UIElement ElementBeingDragged;
        public FrameworkElement OriginalFrameworkElement;
        public Point OriginalPositionOnWindow;
        public Point OriginalPositionOnCanvas;
        public ZComponent ComponentBeingManipulated { get; set; }
        public IEnumerable<ZInformationLandscape> ParentLandscapes { get; set; }

        public Boundary BounceBorder
        {
            get;
            set;
        }

        public Point LastManipulationOrigin
        {
            get;
            set;
        }

        public Point Center
        {
            get;
            set;
        }

        public double GetScaleFactor()
        {
            if (ParentLandscapes == null)
                return 1.0;

            var scale = 1.0;
            foreach (var landscape in ParentLandscapes)
                scale *= landscape.Animation.Position.Zoom;

            return scale;
        }
    }

    public class ObjectDragInformation
    {
        public ObjectDragInformation(Point originalMousePosition)
        {
            OriginalPositionOnWindow = originalMousePosition;
        }

        public Point OriginalPositionOnWindow;
        public Point OriginalPositionOnUIElement;
        public double Top;
        public double Bottom;
        public double Left;
        public double Right;
        public UIElement ElementBeingDragged;
        public FrameworkElement OriginalFrameworkElement;
        public IEnumerable<ZInformationLandscape> ParentLandscapes;

        public double GetScaleFactor()
        {
            if (ParentLandscapes == null)
                return 1.0;

            var scale = 1.0;
            foreach (ZInformationLandscape landscape in ParentLandscapes)
                scale *= landscape.Animation.Position.Zoom;

            return scale;
        }
    }
}
